package com.liao.jta.service.impl;

import com.liao.jta.dao.Test1.Test1UserDao;
import com.liao.jta.dao.test.TestUserDao;
import com.liao.jta.pojo.TbUser;
import com.liao.jta.service.JTAService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class JTAServiceImpl implements JTAService {
    @Autowired
    private TestUserDao userDao;
    @Autowired
    private Test1UserDao userDao1;

    @Transactional
    @Override
    public void saveData() {
        TbUser tbUser = new TbUser();
        tbUser.setUsername("TestUser");
        tbUser.setPassword("123123");
        System.out.println(userDao.saveData(tbUser));
        System.out.println(userDao1.saveData(tbUser));
    }

    @Transactional
    @Override
    public void saveData2() {
        TbUser tbUser = new TbUser();
        tbUser.setUsername("TestUser");
        tbUser.setPassword("123123");
        System.out.println(userDao.saveData(tbUser));
        int i = 1/0;
        System.out.println(userDao1.saveData(tbUser));
    }
}
